package com.ai.bitcoin.util;

import java.io.File;
import java.io.IOException;

public class FileUtil {

    //创建多级目录
    public static File createMultilevelDirectory(String[] directories, String rootPath) {
        if (directories.length == 0) {
            return null;
        }
        File root = new File(rootPath);
        for (int i = 0; i < directories.length; i++) {
            File directory = new File(root, directories[i]);
            directory.mkdir();
            root = directory;
        }
        return root;
    }

    public static File createFileWithMultilevelDirectory(String[] directories,String fileName,String rootName) throws IOException {
        //调用上面的创建多级目录的方法
        File filePath =  createMultilevelDirectory(directories,rootName);
        System.out.println(filePath);
        File file = new File(filePath,fileName);
        file.createNewFile();
        return  file;
    }

}
